package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.YxVipLevels;
import com.ruoyi.system.service.IYxVipLevelsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * vip等级Controller
 * 
 * @author lingyu
 * @date 2024-04-03
 */
@RestController
@RequestMapping("/system/vipLevels")
public class YxVipLevelsController extends BaseController
{
    @Autowired
    private IYxVipLevelsService yxVipLevelsService;

    /**
     * 查询vip等级列表
     */
    @PreAuthorize("@ss.hasPermi('system:vipLevels:list')")
    @GetMapping("/list")
    public TableDataInfo list(YxVipLevels yxVipLevels)
    {
        startPage();
        List<YxVipLevels> list = yxVipLevelsService.selectYxVipLevelsList(yxVipLevels);
        return getDataTable(list);
    }

    /**
     * 导出vip等级列表
     */
    @PreAuthorize("@ss.hasPermi('system:vipLevels:export')")
    @Log(title = "vip等级", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YxVipLevels yxVipLevels)
    {
        List<YxVipLevels> list = yxVipLevelsService.selectYxVipLevelsList(yxVipLevels);
        ExcelUtil<YxVipLevels> util = new ExcelUtil<YxVipLevels>(YxVipLevels.class);
        util.exportExcel(response, list, "vip等级数据");
    }

    /**
     * 获取vip等级详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:vipLevels:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(yxVipLevelsService.selectYxVipLevelsById(id));
    }

    /**
     * 新增vip等级
     */
    @PreAuthorize("@ss.hasPermi('system:vipLevels:add')")
    @Log(title = "vip等级", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YxVipLevels yxVipLevels)
    {
        return toAjax(yxVipLevelsService.insertYxVipLevels(yxVipLevels));
    }

    /**
     * 修改vip等级
     */
    @PreAuthorize("@ss.hasPermi('system:vipLevels:edit')")
    @Log(title = "vip等级", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YxVipLevels yxVipLevels)
    {
        return toAjax(yxVipLevelsService.updateYxVipLevels(yxVipLevels));
    }

    /**
     * 删除vip等级
     */
    @PreAuthorize("@ss.hasPermi('system:vipLevels:remove')")
    @Log(title = "vip等级", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yxVipLevelsService.deleteYxVipLevelsByIds(ids));
    }
}
